"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebVersionModel = void 0;
const ChannelConfig_1 = require("../../src/config/ChannelConfig");
class WebVersionModel {
    constructor(channel, name, strong_version, no_update_version, version) {
        this.channel = channel;
        this.name = name;
        this.strong_version = strong_version;
        this.no_update_version = no_update_version;
        this.version = version;
    }
    static initConfig() {
        // if(Config.environment == Config.EnvironmentType.xj){
        //     this.ios_download_url = "https://down.33eb.cn/MUGAaK"
        //     this.android_download_url = "https://down.33eb.cn/MUGAaK"
        // }else{
        this.ios_download_url = "http://";
        this.android_download_url = "http://8vb6s";
        // }
        this.versionConfig.set(ChannelConfig_1.ChannelConfig.Channel_Type.Web, new WebVersionModel(ChannelConfig_1.ChannelConfig.Channel_Type.Web, "web", "1.0.0", "1.0.0", "1.0.0"));
        this.versionConfig.set(ChannelConfig_1.ChannelConfig.Channel_Type.Ios, new WebVersionModel(ChannelConfig_1.ChannelConfig.Channel_Type.Ios, "Ios", "1.0.0", "1.0.99999", "1.0.999"));
        this.versionConfig.set(ChannelConfig_1.ChannelConfig.Channel_Type.android, new WebVersionModel(ChannelConfig_1.ChannelConfig.Channel_Type.android, "android", "1.0.0", "1.0.99999", "1.0.999"));
    }
    static compareVersion(a_version, b_version) {
        let a = a_version.split(".");
        let b = b_version.split(".");
        for (let i = 0; i < a.length; i++) {
            if (parseInt(a[i]) < parseInt(b[i])) {
                return true;
            }
        }
        return false;
    }
    static getForceUpdate(channel, now_version) {
        let needUpdate = false;
        let model = this.versionConfig.get(channel);
        if (model) {
            if (channel == ChannelConfig_1.ChannelConfig.Channel_Type.Ios) {
                if (now_version == model.no_update_version) { //审核Ios时用
                    return needUpdate;
                }
                else {
                    if (this.compareVersion(now_version, model.strong_version)) {
                        needUpdate = true;
                    }
                }
            }
            else {
                if (this.compareVersion(now_version, model.strong_version)) {
                    needUpdate = true;
                }
            }
        }
        return needUpdate;
    }
    static getNeedUpate(channel, now_version) {
        let needUpdate = false;
        let model = this.versionConfig.get(channel);
        if (model) {
            if (channel == ChannelConfig_1.ChannelConfig.Channel_Type.Ios) {
                if (now_version == model.no_update_version) { //审核Ios时用
                    return needUpdate;
                }
                else {
                    if (this.compareVersion(now_version, model.version)) {
                        needUpdate = true;
                    }
                }
            }
            else {
                if (this.compareVersion(now_version, model.version)) {
                    needUpdate = true;
                }
            }
        }
        return needUpdate;
    }
}
exports.WebVersionModel = WebVersionModel;
//版本控制
WebVersionModel.versionConfig = new Map();
// public static ios_download_url: string = "http://ibirdgame.cn:9604/202109245.apk"
// public static android_download_url: string = "http://ibirdgame.cn:9604/202109245.apk"
WebVersionModel.ios_download_url = "http://cj33.cn";
WebVersionModel.android_download_url = "http://cj33.cn";
